package com.whims.GC;

/**
 * vm options:-XX:+PrintGCDetails(打印GC详细日志)
 * 引用计数GC测试，两个对象互相引用
 */
public class ReferenceCountingGC {

    public Object instance = null;

    private static final int _1MB = 1024 * 1024;

    /**
     * 这个成员变量的意义：占点内存，能在GC日志看清楚是否被回收过
     */
    private byte[] bigSize = new byte[2 * _1MB];

    public static void main(String [] args){
        ReferenceCountingGC a = new ReferenceCountingGC();
        ReferenceCountingGC b = new ReferenceCountingGC();
        //互相引用
        a.instance = b;
        b.instance = a;
        a = null;
        b = null;
        System.gc();
    }

}
